package cn.hnu.qq.global;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.SocketAddress;

public class SocketUtil {

	private ServerSocket ss;
	
	public SocketUtil() {
		try {
			ss = new ServerSocket();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public  boolean isPortUsed(int port){
		InetSocketAddress isa = new InetSocketAddress(port);
		try {
			ss.bind(isa);
		} catch (IOException e) {
			return false;
		}
		
		return true;
	}
}
